package com.universest.swordholder.model.textaction

import com.universest.swordholder.model.prompt.PROMPT_COMMENT
import com.universest.swordholder.model.prompt.PROMPT_REWRITE
import com.universest.swordholder.model.prompt.PROMPT_WRITE
import com.universest.swordholder.model.prompt.Prompt

enum class AiActionType {
    GENERATE_TEXT, //生成文本，插入文字。
    REWRITE_TEXT, //重写文本，替换文字。
    COMMENT //对内容进行评论。
}

class AiAction(val name: String,val prompt: Prompt, val type: AiActionType){
    @Override
    override fun toString(): String {
        return name
    }
}

interface PromptParams{
    fun toMap(): Map<String, String>
}

class GenerateTextParams(
    val novelInfo: String,
    val previousChapters: String,
    val currentChapter: String,
    val writingRequirements: String,
    val contentRequirements: String,
    val continueContent: String
): PromptParams{
    override fun toMap(): Map<String, String> {
        return mapOf(
            "novelInfo" to novelInfo,
            "previousChapters" to previousChapters,
            "currentChapter" to currentChapter,
            "writingRequirements" to writingRequirements,
            "contentRequirements" to contentRequirements,
            "continueContent" to continueContent
        )
    }
}

class RewriteTextParams(
    val novelInfo: String,
    val previousChapters: String,
    val currentChapter: String,
    val writingRequirements: String,
    val paragraph: String,
    val continueContent: String
): PromptParams{
    override fun toMap(): Map<String, String> {
        return mapOf(
            "novelInfo" to novelInfo,
            "previousChapters" to previousChapters,
            "currentChapter" to currentChapter,
            "writingRequirements" to writingRequirements,
            "paragraph" to paragraph,
            "continueContent" to continueContent
        )
    }
}

class CommentParams(
    val novelInfo: String,
    val previousChapters: String,
    val currentChapter: String,
    val selectedParagraph: String,
    val question: String
): PromptParams{
    override fun toMap(): Map<String, String> {
        return mapOf(
            "novelInfo" to novelInfo,
            "previousChapters" to previousChapters,
            "currentChapter" to currentChapter,
            "selectedParagraph" to selectedParagraph,
            "question" to question
        )
    }
}
fun getAiActionList(): List<AiAction> {
    return listOf(
        AiAction("续写文本", PROMPT_WRITE, AiActionType.GENERATE_TEXT),
        AiAction("润色文本", PROMPT_REWRITE, AiActionType.REWRITE_TEXT),
        AiAction("提问评价", PROMPT_COMMENT, AiActionType.COMMENT)
    )
}